package com.example.dryyzx.dao;

import com.example.dryyzx.entity.Bed;
import org.apache.ibatis.jdbc.SQL;

public class BedSqlProvider {
    public String insertSelective(Bed record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("bed");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getBedNumber() != null) {
            sql.VALUES("bed_number", "#{bedNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getRoomNumber() != null) {
            sql.VALUES("room_number", "#{roomNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getFloor() != null) {
            sql.VALUES("floor", "#{floor,jdbcType=VARCHAR}");
        }
        
        if (record.getPosition() != null) {
            sql.VALUES("position", "#{position,jdbcType=VARCHAR}");
        }
        
        if (record.getBedStatus() != null) {
            sql.VALUES("bed_status", "#{bedStatus,jdbcType=VARCHAR}");
        }
        
        if (record.getIsOccupied() != null) {
            sql.VALUES("is_occupied", "#{isOccupied,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Bed record) {
        SQL sql = new SQL();
        sql.UPDATE("bed");
        
        if (record.getBedNumber() != null) {
            sql.SET("bed_number = #{bedNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getRoomNumber() != null) {
            sql.SET("room_number = #{roomNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getFloor() != null) {
            sql.SET("floor = #{floor,jdbcType=VARCHAR}");
        }
        
        if (record.getPosition() != null) {
            sql.SET("position = #{position,jdbcType=VARCHAR}");
        }
        
        if (record.getBedStatus() != null) {
            sql.SET("bed_status = #{bedStatus,jdbcType=VARCHAR}");
        }
        
        if (record.getIsOccupied() != null) {
            sql.SET("is_occupied = #{isOccupied,jdbcType=BIT}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}